package kr.totalcall.service
{
	/**
	 * 작업 기록
	 * 2012. 6. 19. / 이규광 / 최초 작성.
	 */
	/**
	 * 내용.
	 * @productversion Flex 4.5
	 * @langversion ActionScript 3.0
	 * @playerversion Flash 10.2
	 * @author 이규광.
	 */
	import kr.totalcall.constant.URL;
	
	import mx.controls.Alert;
	import mx.rpc.AsyncToken;
	import mx.rpc.events.FaultEvent;
	import mx.rpc.events.ResultEvent;
	import mx.rpc.http.mxml.HTTPService;
	
	public class HttpService extends HTTPService
	{
		
		public var isRunning:Boolean = false;
		
		/**
		 * 생성자
		 */
		public function HttpService(rootURL:String=null, destination:String=null)
		{
			rootURL = URL.urlMain;
			
			super(rootURL, destination);
			
			resultFormat = "e4x";
			addEventListener(ResultEvent.RESULT, resultHandler);
			addEventListener(FaultEvent.FAULT, faultHandler);
		}
		
		override public function send(parameters:Object=null):AsyncToken{
			//trace(this.url + " : send..");
			cancel();
			clearResult();
			
			useProxy = false;
			method = "POST";
			isRunning = true;
			
			return super.send(parameters);
		}
		
		
		public function resultHandler(event:ResultEvent):void{
			isRunning = false;
		}
		
		
		public function faultHandler(event:FaultEvent):void{
			Alert.show(event.fault.message);
			isRunning = false;
		}
		
		
	}
}